package com.xy.job.executor.core.job

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlin.coroutines.CoroutineContext

/**
 * 执行调度任务的协程作用域
 */
internal object ExecutorCoroutineScope : CoroutineScope {

    /**
     * 用于管理所有协程的生命周期
     */
    private val manager = Job()

    override val coroutineContext: CoroutineContext
        get() = Dispatchers.IO + manager

    fun cancelJobs() {
        manager.cancel()
    }
}